<template>
  <section class="my-runlegdetail">
    <div class="status flex flex-between flex-middle">
      <span class="font1">订单状态</span>
      <span class="font1" v-if="info.orderStatus == 1">待接单</span>
      <span class="font1" v-else-if="info.orderStatus == 2">已接单</span>
      <span class="font1" v-else-if="info.orderStatus == 3">开始任务</span>
      <span class="font1" v-else-if="info.orderStatus == 4">蚁兵完成任务</span>
      <span class="font1" v-else-if="info.orderStatus == 5">用户确认完成</span>
      <span class="font1" v-else-if="info.orderStatus == 6">任务已评价</span>
    </div>
    <div class="info">
      <div>
        <van-row>
          <van-col span="10">
            <img class="icon" src="/static/images/errand/icon9.png" alt />
            <span class="font1">任务类型</span>
          </van-col>
          <van-col span="14">
            <span class="font1" v-if="info.taskTypeId == 1">跑腿</span>
            <span class="font1" v-else-if="info.taskTypeId == 2">签到</span>
          </van-col>
        </van-row>
      </div>
      <div>
        <van-row>
          <van-col span="10">
            <img class="icon" src="/static/images/errand/icon3.png" alt />
            <span class="font1">任务名称</span>
          </van-col>
          <van-col span="14">
            <span class="font1">{{info.taskName}}</span>
          </van-col>
        </van-row>
      </div>
      <div>
        <van-row>
          <van-col span="10">
            <img class="icon" src='/static/images/errand/icon4.png' alt />
            <span class="font1">任务金额</span>
          </van-col>
          <van-col span="14">
            <span class="price">{{info.orderAmt}}</span>
            <span class="font1">元</span>
          </van-col>
        </van-row>
      </div>
      <div>
        <van-row>
          <van-col span="10">
            <img class="icon" src="/static/images/errand/icon7.png" alt />
            <span class="font1">联系人</span>
          </van-col>
          <van-col span="14">
            <span class="font1">{{info.linkMan}}</span>
          </van-col>
        </van-row>
      </div>
      <div v-if="info.linkTel">
        <van-row>
          <van-col span="10">
            <img class="icon" src="/static/images/errand/icon8.png" alt />
            <span class="font1">联系电话</span>
          </van-col>
          <van-col span="14">
            <span class="font1">{{info.linkTel}}</span>
          </van-col>
        </van-row>
      </div>
    </div>
    <div class="place">
      <div>
        <img class="icon" src="/static/images/errand/icon2.png" alt />
        <span class="font1">任务地点</span>
      </div>
      <div class="det">
        <div class="font1">{{info.taskAreaId + info.taskDtlAddr}}</div>
        <!-- <div class="desc">{{info.taskName}}</div> -->
      </div>
    </div>
    <div class="place">
      <div>
        <img class="icon" src="/static/images/errand/icon1.png" alt />
        <span class="font1">收货地点</span>
      </div>
      <div class="det">
        <div class="font1">{{info.taskReceiveAreaId + info.taskReceiveDtlAddr}}</div>
        <!-- <div class="desc">{{info.taskName}}</div> -->
      </div>
    </div>
    <div class="info">
      <div class="flex flex-between flex-middle">
        <div>
          <img class="icon" src="/static/images/errand/icon6.png" alt />
          <span class="font1">任务日期</span>
        </div>
        <span class="time">{{info.taskDate}}</span>
      </div>
      <div class="flex flex-between flex-middle">
        <div>
          <img class="icon" src="/static/images/errand/icon5.png" alt />
          <span class="font1">任务时间</span>
        </div>
        <span class="time">{{info.taskBeginTime}}</span>
      </div>
    </div>
    <!-- 备注 -->
    <div class="remark">
      <van-row>
        <van-col span="3">
          <span class="font1">备注:</span>
        </van-col>
        <van-col span="21">
          <span class="font1">
           {{info.taskRemark}}
          </span>
        </van-col>
      </van-row>
    </div>
    <!-- 参考图片 -->
    <div class="reference">
      <div class="font1">任务参考图片</div>
      <div class="imgs">
        <img v-for="(n,i) in info.imgList" :key="i" :src='n.imageUrl' @click="preImg(n.imageUrl)"/>
      </div>
    </div>
    <button v-if="!owner" class="orders" @click="makeTaskOrder(1)">接单</button>
  </section>
</template>
<script>
import {cutTime} from '@/utils/filters.js';
export default {
  data() {
    return {
      orderId:'',
      info:'',
      owner: false
    };
  },
  onLoad(e) {
    this.orderId = e.id?e.id:'201909160000002294555856';
    this.selectOrderDetail();
  },
  methods: {
    preImg(url) {
      console.log(url);
      let urls = this.info.imgList.map((item) => {
        return item.imageUrl
      })
      wx.previewImage({
        current: url, // 当前显示图片的http链接
        urls // 需要预览的图片http链接列表
      })
    },
    routerTo(id) {
      wx.navigateTo({ url: "../runlegdetail/index?id=" + id });
    },
    selectOrderDetail(){
      this.$api.selectOrderDetail({orderId: this.orderId}).then(res => {
        res.data.order.imgList = res.data.imgList;
        res.data.order.taskDate = cutTime(res.data.order.taskDate);
        this.info = res.data.order;

      })
    },
    //1.接单2.完成 3.开始订单4.放弃订单
    makeTaskOrder(type){
      this.$api.makeTaskOrder({orderId: this.orderId,type}).then(res => {
        if(res.code == 0){
          wx.navigateTo({ url: '/pages/order/taskDetail/main?id='+this.orderId });
          // wx.showToast({
          //   title: res.msg, //提示的内容,
          //   icon: 'none', //图标,
          //   duration: 2000, //延迟时间,
          //   mask: true, //显示透明蒙层，防止触摸穿透,
          //   success: res => {

          //   }
          // });
        }
      })
    }
  }
};
</script>
<style lang="scss" scoped>
.my-runlegdetail {
  .status {
    background: rgba(255, 255, 255, 1);
    border-radius: 5px;
    margin: 15px 10px;
    padding: 20px 15px;
  }
  .info {
    margin: 15px 10px;
    padding: 0 10px;
    background: rgba(255, 255, 255, 1);
    border-radius: 5px;
    & > div {
      padding: 20px 0;
    }
    & > div:not(:last-child) {
      border-bottom: 1px solid #f2f2f2;
    }
    .icon {
      margin-right: 6px;
    }
    .price {
      font-size: 15px;
      font-family: PingFang;
      font-weight: 500;
      color: rgba(59, 184, 253, 1);
      line-height: 13px;
      vertical-align: middle;
    }
    .time {
      font-size: 12px;
      font-family: DIN;
      font-weight: 500;
      color: rgba(46, 46, 46, 1);
      line-height: 13px;
    }
  }
  .place {
    margin: 15px 10px;
    .font1 {
      margin-left: 6px;
    }
    .det {
      margin-top: 8px;
      padding: 20px;
      background: rgba(255, 255, 255, 1);
      border-radius: 5px;
      .font1 {
        margin-left: 0;
      }
      .desc {
        font-size: 12px;
        font-family: PingFang;
        font-weight: 500;
        color: rgba(193, 196, 201, 1);
        line-height: 13px;
        margin-top: 20px;
      }
    }
  }
  .remark {
    background: rgba(255, 255, 255, 1);
    border-radius: 5px;
    margin: 15px 10px;
    padding: 20px 10px;
    .font1 {
      line-height: 24px;
    }
  }
  .orders {
    margin: 30px 15px;
    background: rgba(59, 184, 253, 1);
    border-radius: 5px;
    font-size: 15px;
    font-family: PingFang;
    font-weight: 500;
    color: rgba(255, 255, 255, 1);
  }
  .reference {
    padding: 15px 10px;
    background: rgba(255, 255, 255, 1);
    border-radius: 5px;
    margin: 15px 10px;
    .font1 {
      margin-bottom: 15px;
    }
    .imgs {
      img {
        width: 60px;
        height: 60px;
        border-radius: 1px;
        &:not(:last-child){
          margin-right: 9px;
        }
      }
    }
  }
  .font1 {
    font-size: 13px;
    font-family: PingFang;
    font-weight: 500;
    color: rgba(46, 46, 46, 1);
    line-height: 13px;
    vertical-align: middle;
  }
  .icon {
    width: 14px;
    height: 14px;
    vertical-align: middle;
  }
}
</style>
<style lang="scss">
page {
  background: #f7f7f7;
}
</style>